home *** CD-ROM | disk | FTP | other *** search
/ Java Certification Exam Guide / McGrawwHill-JavaCertificationExamGuide.iso / pc / Web Links and Code / code / chap20 / TopFrame.java < prev    next >
Encoding:
Java Source  |  1997-04-20  |  549 b   |  25 lines

  1. import java.awt.*;
  2.  
  3. /**
  4.  * The top-level frame for the user interface.
  5.  * This class gives the ui a home and knows how to exit gracefully.
  6.  */
  7. public class TopFrame extends Frame {
  8.  
  9.    /** Construct a frame with a title. */
  10.    public TopFrame(String s) {
  11.       super(s);
  12.    }
  13.  
  14.    /** Handles the user clicking the close icon. */
  15.    public boolean handleEvent(Event e) {
  16.       if (e.id == Event.WINDOW_DESTROY) {
  17.          hide();
  18.          dispose();
  19.          System.exit(0);
  20.       }
  21.       return super.handleEvent(e);
  22.    }
  23.  
  24. }
  25.